﻿
-- =============================================
-- Author:		<赵洪涛>
-- Create date: <2012-03-03>
-- Description:	<更新订单编号>
-- =============================================
CREATE PROCEDURE [dbo].[proc_order_updateBH] 
as
BEGIN
declare @rq varchar(10)
set @rq='2012-03-05'

--Update aa Set aa.OrderId=bb.orderid From [order] aa,(Select a.*,a.bh+replicate('0',4-len(row))+convert(varchar(4),row) as orderid
--From 
--(SELECT id,ROW_NUMBER() OVER (ORDER BY [FinanceRenlingDate]) AS Row
--,convert(varchar(10),[FinanceRenlingDate],112) as bh
--      ,[CompanyId]
--      ,[FinanceRenlingDate]
--FROM [Order]
--where convert(varchar(10),[FinanceRenlingDate],120)=@rq and stateid>=2) as a) bb
--where aa.id=bb.id

Select * From [order] where convert(varchar(10),[FinanceRenlingDate],120)=@rq and stateid>=2 order by [FinanceRenlingDate]
END


